package com.foreveross.fetl.core.domain.task;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.domain.BaseOracleEntity;
import com.foreveross.fetl.core.domain.task.repository.SourceEntityRepository;


@javax.persistence.Entity
@Table(name = "FDC_SOURCE")
public class SourceEntity extends BaseOracleEntity{

	private static final long serialVersionUID = 1186497672071435028L;
	
	@Id
	private Long id;
	
	@Column(name = "NAME")
	private String name;
	
	
	@Column(name = "CARRIER_KEY")
	private String carrierKey;
	
	@Column(name = "SHORT_NAME")
	private String shortName;
	
	@Column(name = "URL")
	private String url;
	
	@Column(name = "WEB_TYLE")
	private String webTyle;
	
	
	@Column(name="CRAWL_STATUS")
	private Integer crawlStatus;
	
	@Column(name="USER_CREATETIME")
	private Date createTime;
	
	
	
	/**
	 * 渠道
	 */
	public static String TYPE_CHNNAEL = "0";
	/**
	 * 官网
	 */
	public static String TYPE_HOME = "1";
	
	@Column(name = "HBASE_KEY")
	private String hbaseKey;
	
	
	public String getWebTyle() {
		return webTyle;
	}

	public void setWebTyle(String webTyle) {
		this.webTyle = webTyle;
	}

	public String getHbaseKey() {
		return hbaseKey;
	}

	public void setHbaseKey(String hbaseKey) {
		this.hbaseKey = hbaseKey;
	}	

	public String getCarrierKey() {
		return carrierKey;
	}

	public void setCarrierKey(String carrierKey) {
		this.carrierKey = carrierKey;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	
	
	public Integer getCrawlStatus() {
		return crawlStatus;
	}

	public void setCrawlStatus(Integer crawlStatus) {
		this.crawlStatus = crawlStatus;
	}
	
	

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public SourceEntityRepository getBaseEntityRepository() {
		return InstanceFactory.getInstance(SourceEntityRepository.class);
	}
	
	public List<SourceEntity> findSourceEntityByType(String type) {
		return getBaseEntityRepository().findSourceEntityByType(type);
	}
	
	public List<SourceEntity> findByHbaseKey(String channel) {
		return getBaseEntityRepository().findByHbaseKey(channel);
	}
	public List<SourceEntity> findAll(){
		return getBaseEntityRepository().findAll(SourceEntity.class);
	}
	
	/**
	 * 找出创建时间小于等于当前时间
	 * @param createTime
	 * @return
	 */
	public List<SourceEntity> findlessCreateTime(Date createTime){
		return getBaseEntityRepository().findlessCreateTime(createTime);
	}
}
